<!DOCTYPE html>
<html>
  <head>
    <title>获取video封面</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src='./js/poster.js'></script>
    <script type="text/javascript">
      onload=function(){
        //var poster=poster();
        v=document.getElementById('v');
        var p=document.getElementById('poster1');

        document.getElementById('jie').onclick=function(){
          console.log(v);
          poster(v,function(e){
            //console.log(e);
            //console.log(e.data);
            if(e.bool){
              //输出文件对象
              var blob=e.data;
              console.log(blob);
              p.src=window.URL.createObjectURL(e.data);
            }

          });


        }
      }
    </script>
  </head>
<body>

  <video id="v" class="video-js vjs-default-skin" controls preload="auto" width="640" poster="./poster.png" height="264" >
    <source src="./movie.webm" type="video/webm">
    <source src="./movie.ogg" type="video/ogg">
    <p class="vjs-no-js">你的浏览器不支持video,请升级浏览器尝试。</a></p>
  </video>
  <button id='jie'>截图</button>
  <img src="" id="poster1">
</body>
</html>
